<?php
header('Content-type: application/json'); //json
$url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$arrUrl = explode('/', $url);

if ($arrUrl[1] == 'versionList') {

    // 实现版本列表
    $resource = scandir("./");
    $blackArr = ['..', '.', '.git'];
    foreach ($resource as $k => $v) {
        if (!in_array($v, $blackArr) and is_dir($v)) {
            $res[] = $v;
        }

    }

    $resArr = [
        'code' => 200,
        'data' => [
            'list' => $res,
            'dataCount' => count($res),
        ],
    ];
    echo json_encode($resArr, JSON_UNESCAPED_UNICODE);return;
}

echo '{"code": 400, "error": "版本不存在!"}';